import React, { useEffect, lazy } from 'react'
import { Layout, Menu } from 'antd';
import { ajax } from '../../api';
import myinfo from '../mobx/info';
import Foot from './Foot';
import Head from './Head';
import { Switch, Route, Redirect } from 'react-router-dom';
import Mianbao from './mianbao';
import MenuCpt from './Menu';
const { Header, Content, Footer, Sider } = Layout;
export default function MainIndex(props: any) {

    const getuserinfo = async () => {
        let res: any = await ajax.getuserinfo()
        myinfo.changeInfo(res.result)
        // console.log(res);

    }
    useEffect(() => {
        getuserinfo()

    }, [])


    return (
        <Layout style={{ width: "100%", height: "100%" }}>
            <MenuCpt></MenuCpt>
            <Layout>
                <Head {...props}></Head>
                <Mianbao></Mianbao>
                <Content style={{ padding: "10px 20px 20px 20px" }} >

                    {/* 子路由 */}
                    <div className='content' style={{ borderRadius: '5px', padding: 16, boxShadow: '2px 2px 3px  2px #b5b5b5', height: '100%', overflow: "auto" }} >

                        <Switch>
                            <Route path="/main" exact component={() => (<Redirect to="main/home" />)}></Route>
                            <Route path="/main/home" component={lazy(() => import("../home/home"))}></Route>
                            <Route path="/main/infos" component={lazy(() => import("../infos/index"))}></Route>

                            <Route  path="/main/user" component={() => (
                                <Switch >
                                    <Route path="/main/user/list" component={lazy(() => import("../users/Listuser"))}></Route>
                                    <Route path="/main/user/add" component={lazy(() => import("../users/Adduser"))}></Route>
                                    <Route path="/main/user/anylist" component={lazy(() => import("../users/Fenxiuser"))}></Route>
                                </Switch>
                            )}></Route>

                            <Route path="/main/anno" component={() => (
                                <Switch>
                                    <Route path="/main/anno/list" component={lazy(() => import("../annos/Listanno"))}></Route>
                                    <Route path="/main/anno/add" component={lazy(() => import("../annos/Addanno"))}></Route>
                                </Switch>
                            )}></Route>

                            <Route path="/main/advise" component={() => (
                                <Switch>
                                    <Route path="/main/advise/list" component={lazy(() => import("../advise/Listadvise"))}></Route>
                                    <Route path="/main/advise/add" component={lazy(() => import("../advise/Addadvise"))}></Route>
                                </Switch>
                            )}></Route>

                            <Route path="/main/jiaowu" component={() => (
                                <Switch>
                                    <Route path="/main/jiaowu/xueke" component={lazy(() => import("../jiaowu/Xueke"))}></Route>
                                    <Route path="/main/jiaowu/banji" component={lazy(() => import("../jiaowu/Banji"))}></Route>
                                    <Route path="/main/jiaowu/oa" component={lazy(() => import("../jiaowu/Oajiaowu"))}></Route>
                                </Switch>
                            )}></Route>





                            <Route component={() => (<Redirect to="/404" />)} />
                        </Switch>
                    </div>
                </Content>
                <Footer style={{ background: "#f4f4f4", borderTop: "1px solid #999", height: "60px" }}>
                    <Foot ></Foot>
                </Footer>
            </Layout>
        </Layout >
    )
}
